<%@page import="cn.ysnk.clz.util.dateUtil.DateUtil"%>
<%@page import="cn.ysnk.clz.entity.menu.AdminMenu"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%
List<AdminMenu> menuList = (List<AdminMenu>)request.getAttribute("menuList");
%>
</head>
<body>
	<div class="default-padding container-fluid">
		<div class="page-header">
		  <h3>通过菜单管理来编辑您的菜单，每一个菜单将会在后台左侧显示出来</h3>
		</div>
		<button type="button" onclick="addMenu()" class="btn btn-primary default-margin-bottom">新增菜单</button>
		<table class="table table-bordered table-hover">
			<thead>
				<tr>
					<th>序号</th>
					<th>菜单名称</th>
					<th>菜单图标</th>
					<th>添加时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			<%
			int index = 1;
		    for(AdminMenu menu:menuList){
		    %>
		    	<tr>
		    		<td><%=index++ %></td>
		    		<td><%=menu.getStr("name") %></td>
		    		<td>
			    		<div class="inline-block">
				    		<span class="glyphicon glyphicon-<%=menu.getStr("icon") %>" aria-hidden="true"></span><span>glyphicon-<%=menu.getStr("icon") %></span>
				    	</div>
		    		</td>
		    		<td><%= DateUtil.DateToString(menu.getDate("updateTime"),"yyyy-MM-dd") %></td>
		    		<td>
		    			<button type="button" onclick="editMenu('<%=menu.getStr("id") %>')" class="btn btn-info">修改</button>
		    			<button type="button" onclick="deleteMenu('<%=menu.getStr("id") %>')" class="btn btn-warning">删除</button>
		    			<button type="button" onclick="showSubMenu('<%=menu.getStr("id") %>')" class="btn btn-primary">查看子菜单</button>
		    		</td>
		    	</tr>
		    <%
		    }
		    %>
			</tbody>
		</table>
	</div>
	<script type="text/javascript">
	function deleteMenu(menuId){
		var submit = function (v, h, f) {
		    if (v == 'ok')
		    	ajaxDataPost("/adminMenu/deleteMenu",{menuId:menuId},refreshAdmin,function(){});
		    return true; //close
		};
		$.jBox.confirm("确定删除该菜单吗？", "提示", submit);
	}

	function addMenu(){
		refreshTab('/adminMenu/editMenu');
	}

	function editMenu(menuId){
		refreshTab('/adminMenu/editMenu?menuId='+menuId);
	}

	function menuback(){
		refreshTab('/adminMenu/manage');
	}


	function showSubMenu(menuId){
		$("#myLargerModal").modal({
		    remote: path+"/adminMenu/subMenuList?menuId="+menuId
		});
	}

	</script>
</body>
</html>